import {
	PickupViewActionType,
	IPickupViewAbility,
	IPickupViewControllerParams,
	IPickupViewModel,
	IPickupViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	handlePickupViewButtonAction,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取数据选择视图输入参数
 *
 * @export
 * @return {*}
 */
export function usePickupViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取数据选择视图基础
 *
 * @export
 * @param {IPickupViewModel} model 数据选择视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function usePickupViewBasic(model: IPickupViewModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
		handlePickupViewButtonAction,
	};
}

/**
 * 数据选择视图行为
 *
 * @export
 */
export function usePickupViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取数据选择视图控制器输入参数
 *
 * @export
 * @param {IPickupViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<PickupViewActionType, IPickupViewAbility>>} evt
 * @return {*}  {IPickupViewControllerParams<PickupViewActionType, IPickupViewAbility>}
 */
export function usePickupViewControllerParams(
	model: IPickupViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<PickupViewActionType, IPickupViewAbility>>
): IPickupViewControllerParams<PickupViewActionType, IPickupViewAbility> {
	return {
		...useViewControllerParams<IPickupViewStore, IPickupViewModel>(
			model,
			props,
			evt
		),
	};
}
